#ifndef _MAXHEAP_H_
#define _MAXHEAP_H_

#include <string.h>
#include <stdlib.h>
#include "entity.h"

#define BOOL unsigned short

#define false 0
#define true  1

#define DEFAULT_SIZE   10


struct Maxheap
{
	struct Data *array;
	unsigned size;
	unsigned count;
};

struct Maxheap *createMaxheap(struct Data *, int len);
BOOL removeMax(struct Maxheap *_heap, struct Data *_pdata);
void delMaxheap(struct Maxheap *);
int leftchild(int pos);
int rightchild(int pos);
int parent(int pos);
BOOL insert(struct Maxheap *, struct Data *);
BOOL isLeaf(struct Maxheap *, int pos);
void buildHeap(struct Maxheap *);
void siftdown(struct Maxheap *, int pos);

#endif
